<template>
	<view style="background-color: #F8FBFB;">
		<view style="height: 113rpx;width: 100%;background: #00BAAD;color: #FFFFFF;font-size: 32rpx;font-weight: bold;text-align: center;line-height: 113rpx;">
			<text>NO：{{recipeCode}}</text>
		</view>
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;font-size: 30rpx;">
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );padding-top: 31rpx;margin-bottom: 31rpx;">
				<text>就诊人：</text>
				<text>{{treatName}}</text>
			</view>
			
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );margin-bottom: 31rpx;">
				<text>年龄：</text>
				<text>{{recipeInfo.treatAge}}</text>
			</view>
			<!-- <view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );padding-top: 31rpx;margin-bottom: 31rpx;">
				<text>体重：</text>
				<text>{{recipeInfo.treatAge}}</text>
			</view> -->
			
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );margin-bottom: 31rpx;">
				<text>电话：</text>
				<text  style="color: #2A82E4;">{{recipeInfo.mobile}}</text>
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );margin-bottom: 31rpx;">
				<text>科室：</text>
				<text>{{doctorDept}}</text>
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );padding-bottom: 31rpx;">
				<text>日期：</text>
				<text v-if="recipeInfo&&recipeInfo.treatDate">{{changeDateFormat(recipeInfo.treatDate)}}</text>
			</view>
		</view>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
			<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
				患者症状描述：
			</view>
			<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
				{{recipeInfo&&recipeInfo.problem&&recipeInfo.problem!='undefined'?recipeInfo.problem:''}}
			</view>
		</view>
		
		<template v-if="chinRecipeType==2">
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					中医诊断：
				</view>
				<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
					<text>{{recipeInfo.disNames}}</text>
				</view>
			</view>
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					西医诊断：
				</view>
				<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
					<text v-for=" diseaItem in recipeInfo.diseaInfo" :key="diseaItem.diseDiseaseId">{{diseaItem.name+' '}}</text>
				</view>
			</view>
			
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					中医辨证：
				</view>
				<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
					<text>{{recipeInfo.symNames}}</text>
				</view>
			</view>
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					中医治法：
				</view>
				<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
					<text>{{recipeInfo.theNames}}</text>
				</view>
			</view>
			
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					处方类型：
				</view>
				<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
					<text>中医处方</text>
				</view>
			</view>
		</template>
		<template v-else>
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					诊断：
				</view>
				<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
					<text v-for=" diseaItem in recipeInfo.diseaInfo" :key="diseaItem.diseDiseaseId">{{diseaItem.name+' '}}</text>
				</view>
			</view>
		</template>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
			<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
				诊疗意见：
			</view>
			<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
				{{entrustDoc}}
			</view>
		</view>
		<template v-if="chinRecipeType==2">
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					RP:
				</view>
				<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
					<view style="background-color: #F4F4F4;display: flex;align-items: center;justify-content: space-between;padding:20rpx 40rpx;">
						<text style="font-size: 30rpx;font-weight: 400;color: #424C4C;">中医处方</text>
						<view style="font-size: 30rpx;font-weight: 400;color: #FF8D1A;">
							<text style="margin-right: 10rpx;">{{recipeInfo.recipeNumber}}剂</text>
							<text>￥{{recipeInfo.drugsFee}}</text>
						</view>
					</view>
					<template ><!-- v-if="payState == 1 || payState == 2" -->
						<view style="border: 2rpx solid #EFEFEF;display: flex;align-items: center;padding:20rpx 40rpx;flex-wrap: wrap;justify-content: space-between;">
							<view v-for="(item,index) in userRecipeDrug" :key="item.id">
								<text style="font-size: 28rpx;color: #424C4C;">{{item.drugName}}</text>
							</view>
						</view>
						<view style="font-size: 26rpx;color: #FF8D1A;font-weight: 400;margin-top: 23rpx;">
							tips：医生独家处方，不便提供数量
						</view>
					</template>
					<!-- <template v-else>
						<view style="font-size: 26rpx;color: #FF8D1A;font-weight: 400;margin-top: 23rpx;">
							处方详情在支付后可见
						</view>
					</template> -->
				</view>
			</view>
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;" v-if="payState == 1 || payState == 2">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					用法用量：
				</view>
				<view style="width: calc( 100% - 80rpx );padding-bottom: 31rpx;">
					<view style="display: flex;align-items: center;justify-content: space-between;padding-top: 31rpx;margin-bottom: 31rpx;">
						<text>给药途径：</text>
						<text>{{recipeInfo.drugRoutes}}</text>
					</view>
					<view style="display: flex;align-items: center;justify-content: space-between;margin-bottom: 31rpx;">
						<text>执行频次：</text>
						<text>{{recipeInfo.drugFrequencys}}</text>
					</view>
					<view style="display: flex;align-items: center;justify-content: space-between;margin-bottom: 31rpx;">
						<text>单次剂量：</text>
						<text>{{recipeInfo.drugDosages}}</text>
					</view>
					<view style="display: flex;align-items: center;justify-content: space-between;">
						<text>执行天数</text>
						<text>{{recipeInfo.useTimes}}天</text>
					</view>
				</view>
			</view>	
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;" v-if="payState == 1 || payState == 2">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
					附特殊药品用法：
				</view>
				<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
					<text v-if="item.specialUse">{{item.specialUse+' '}}{{item.speciaUseTime}}</text>
					<text v-else>暂无特殊用法</text>
				</view>
			</view>	
		</template>
		<template v-else>
			<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
				<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;
					height: 80rpx;line-height: 80rpx;font-weight: bolder;display: flex;align-items: center;justify-content: space-between;
					padding-right: 40rpx;box-sizing: border-box;width: calc( 100% - 40rpx );">
					<text>RP:</text>
					<text style="font-size: 30rpx;font-weight: 400;color: #FF8D1A;">药品总计：￥{{recipeInfo.drugsFee}}</text>
				</view>
				<view v-for="(item,index) in userRecipeDrug" :key="item.id"
					style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;"> <!-- v-if="payState == 1 || payState == 2" -->
					<view style="background-color: #F4F4F4;display: flex;align-items: center;justify-content: space-between;padding:20rpx 40rpx;">
						<text style="font-size: 30rpx;font-weight: 400;color: #424C4C;">{{item.drugName}}</text>
						<view style="font-size: 30rpx;font-weight: 400;">
							<text style="margin-right: 10rpx;">小计：</text>
							<text>￥{{item.price}}</text>
						</view>
					</view>
					<view style="border: 2rpx solid #EFEFEF;padding:20rpx 40rpx;">
						<view style="display: flex;align-items: center;justify-content: space-between;color: #B0B0B0;">
							<text>{{item.drugSpecificationName}}</text>
							<text>*{{item.num}}</text>
						</view>
						<view style="color: #B0B0B0;margin-top: 19rpx;">
							sig:<text style="margin-right: 10rpx;">{{item.drugRoute}}</text>
							<text style="margin-right: 10rpx;">{{item.drugFrequency}}</text>
							<text style="margin-right: 10rpx;">每次{{item.drugDosage}}</text>
						</view>
					</view>
				</view>
				
				<!-- <view style="font-size: 26rpx;color: #FF8D1A;font-weight: 400;margin-top: 23rpx;padding-bottom: 20rpx;" v-else>
					处方详情在支付后可见
				</view> -->
			</view>
		</template>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;" v-if="payState == 0&&chinRecipeType==2&&recipeInfo.decoctionFee">
			<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
				是否选择药品代煎服务<text style="font-size: 28rpx;color: rgba(255, 141, 26, 1);">tips：代煎费用5元/副</text>
			</view>
			<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
				<radio-group style="width: 100%;display: flex;align-items: center;justify-content: space-between;">
					<view class="flex flex-ac mr30" @click="changeDJMode(0)">
						<text style="margin-right: 10rpx;">否</text>
						<radio value="1" :checked="djMode==0" style="transform:scale(0.6);color: #2A82E4;" color="#2A82E4"/>
					</view>
					<view class="flex flex-ac" @click="changeDJMode(1)">
						<text style="margin-right: 10rpx;">是</text>
						<radio value="0" :checked="djMode==1" style="transform:scale(0.6);color: #2A82E4;" color="#2A82E4"/>
					</view>
				</radio-group>
			</view>
		</view>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;"  v-if="payState == 0">
			<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
				选择取药方式
			</view>
			<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
				<radio-group style="width: 100%;display: flex;align-items: center;justify-content: space-between;" @change="">
					<view class="flex flex-ac mr30" @click="changeBuyMode(1)">
						<text style="margin-right: 10rpx;">送药上门</text>
						<radio value="1" :checked="buyMode==1" style="transform:scale(0.6);color: #2A82E4;" color="#2A82E4"/>
					</view>
					<view class="flex flex-ac" @click="changeBuyMode(0)">
						<text style="margin-right: 10rpx;">到店自提</text>
						<radio value="0" :checked="buyMode==0" style="transform:scale(0.6);color: #2A82E4;" color="#2A82E4"/>
					</view>
				</radio-group>
			</view>
		</view>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;"  v-if="payState == 0 && buyMode==1">
			<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
				收货地址：
			</view>
			<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;display: flex;align-items: center;justify-content: space-between;" @click="toAddress">
				<input class="ft12 c666"  placeholder-class="c999" placeholder="请选择您的收货地址" v-model="adressInfo" />
				<image class="arrow" style="margin: 0rpx;" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;padding-bottom: 31rpx;width: calc( 100% - 80rpx );">
				<text>配送费：</text>
				<text style="font-size: 30rpx;font-weight: 400;color: #FF8D1A;">￥{{recipeInfo.deliveryFee}}</text>
			</view>
		</view>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;">
			<view style="width: calc( 100% - 80rpx );overflow: hidden;text-overflow: ellipsis;white-space: nowrap;padding-top: 31rpx;margin-bottom: 31rpx;">
				<text>药房：</text>
				<text>{{recipeInfo.offcinaPostion.name}}</text>
			</view>
			<view style="width: calc( 100% - 80rpx );padding-bottom: 31rpx;display: flex;align-items: center;justify-content: space-between;">
				<view style="width: calc( 100% - 150rpx );overflow: hidden;text-overflow: ellipsis;white-space: nowrap;font-size: 28rpx;">
					<text>地址：</text>
					<text>{{recipeInfo.offcinaPostion.address}}</text>
				</view>
				<view style="color: #2A82E4;font-size: 28rpx;width: 150rpx;text-align: right;" @click="Navigation">导航到店</view>
			</view>
		</view>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;"  v-if="payState != 0 && buyMode==1">
			<view style="border-bottom: 2rpx solid #f7f7f7;width: calc(100% - 40rpx);">
				<view style="display: flex;align-items: center;justify-content: space-between;height: 80rpx;width: calc(100% - 40rpx);">
					<view style="font-size: 30rpx;font-weight: bolder;color: #424C4C;">物流信息：</view>
					<view style="color: #2A82E4;font-size: 28rpx;text-align: right;">查看物流信息</view>
				</view>
			</view>
			<view style="width: calc( 100% - 80rpx );padding-top: 31rpx;padding-bottom: 31rpx;">
				<view style="display: flex;align-items: center;justify-content: space-between;margin-bottom: 31rpx;">
					<text>接收人：</text>
					<text>{{recipeInfo.addressUserName}}</text>
				</view>
				<view style="display: flex;align-items: center;justify-content: space-between;margin-bottom: 31rpx;">
					<text>联系电话：</text>
					<text>{{recipeInfo.adderssPhone}}</text>
				</view>
				<view style="display: flex;align-items: center;justify-content: space-between;margin-bottom: 31rpx;">
					<text>配送地址：</text>
					<text>{{recipeInfo.adressInfo}}</text>
				</view>
				<view style="display: flex;align-items: center;justify-content: space-between;margin-bottom: 31rpx;">
					<text>配送费：</text>
					<text style="font-size: 30rpx;font-weight: 400;color: #FF8D1A;">￥{{recipeInfo.deliveryFee}}</text>
				</view>
				<view style="display: flex;align-items: center;justify-content: space-between;">
					<view>
						<text>{{recipeInfo.deliverCompany}}</text>
						<text>{{recipeInfo.deliverExpressNumber}}</text>
					</view>
					<view style="color: #2A82E4;font-size: 28rpx;text-align: right;">复制单号</view>
				</view>
			</view>
		</view>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;font-size: 30rpx;margin-top: 20rpx;">
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );padding-top: 31rpx;margin-bottom: 31rpx;">
				<text>医师：</text>
				<text>{{doctorName}}</text>
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );margin-bottom: 31rpx;">
				<text>药师：</text>
				<text>{{auditName}}</text>
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );padding-bottom: 31rpx;">
				<text>开具日期：</text>
				<text>{{changeDateFormat(auditDate)}}</text>
			</view>
		</view>
		
		<view style="width: 100%;padding-left: 40rpx;background-color: #FFFFFF;margin-top: 20rpx;" v-if="chinRecipeType==2">
			<view style="border-bottom: 2rpx solid #f7f7f7;color: #424C4C;font-size: 30rpx;height: 80rpx;line-height: 80rpx;font-weight: bolder;">
				费用明细
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );padding-top: 31rpx;margin-bottom: 31rpx;">
				<text>药品合计：</text>
				<text>{{totalFee}}元</text>
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );margin-bottom: 31rpx;"
				v-if="buyMode==1">
				<text>配送费用：</text>
				<text>{{recipeInfo.deliveryFee}}元</text>
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );padding-bottom: 31rpx;"
					v-if="djMode==1">
				<text>代煎费用：</text>
				<text>{{recipeInfo.decoctionFee}}元</text>
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;width: calc( 100% - 80rpx );padding-bottom: 31rpx;color: rgba(255, 141, 26, 1);">
				<text>总计：</text>
				<text>{{(totalFee*1+(buyMode==1?recipeInfo.deliveryFee*1:0)+(djMode==1?recipeInfo.decoctionFee*1:0)).toFixed(2)}}元</text>
			</view>
		</view>
		
		<view class="pt30 pb30"  v-if="payState == 0">
			<view class="add-btn" @click="payMonty">去支付</view>
		</view>
		<view class="pt30 pb30"  v-else-if="payState == 7">
			<view class="add-btn-del" @click="refuseRefund">拒绝退费</view>
		</view>
		<view class="pt30 pb30"  v-else>
			<view class="add-btn-del">
				{{payState== 1?'已支付':payState== 2?'已派药':payState== 3?'待退款':payState== 4?'已退费':payState== 5?'异常支付':'支付超时'}}
			</view>
		</view>

		<uni-popup ref="popup" type="message">
		    <uni-popup-message :type="warnType" :message=warnMessage :duration="warnTime"></uni-popup-message>
		</uni-popup>
		
		<view class="win flex" v-if="isShowTip" @touchmove.stop="" style="position: fixed;width: 100%;height: 100vh;left: 0;top: 0;">
			<view style="margin: auto;background-color: #FFFFFF;z-index: 999;border-radius: 20rpx;width: 80%;height: 300rpx;display: flex;flex-direction: column;align-items: center;justify-content: space-around;">
				<view style="font-size: 38rpx;text-align: center;font-weight: bolder;">温馨提示</view>
				<view style="font-size: 34rpx;text-align: center;">您所选购的药品将由第三方单位配送</view>
				<view style="display: flex;flex-direction: row;align-items: center;justify-content: space-around;align-items: center;width: 100%;">
					<button type='primary' style="background-color: #F3F3F3;width: 40%;color: #000000;height: 90rpx;line-height: 90rpx;font-size: 30rpx;" @click="isShowTip=false">
						取消
					</button>
					<button type='primary' style="background-color: #1BC1B6;width: 40%;height: 90rpx;line-height: 90rpx;font-size: 30rpx;" @click="payMonty">
						确定
					</button>
				</view>
			</view>
		</view>
		<wyb-popup ref="popup" type="bottom" height="100" width="500" radius="2" :showCloseIcon="true">
				<view class="popup-content">
					<view class="part1">选择支付平台</view>
			<!-- 暂时 -->
<!-- 					<view class="part2" @click="pay1">
 						<image src="@/static/images/medical-logo.png" mode="" style="margin-left: 20rpx;"></image>
						<view class="" style="margin-left: 30rpx;">医保支付</view>
					</view> -->
			
					<view class="part3" @click="pay">
						<image src="@/static/images/wxzf.png" mode="" style="margin-left: 20rpx;"></image>
						<view class="" style="margin-left: 30rpx;">微信支付</view>
					</view>
				</view>
			</wyb-popup>
	</view>
</template>

<script>
	import tkiBarcode from "@/components/tki-barcode/tki-barcode.vue"
	import wybPopup from '@/components/wyb-popup/wyb-popup.vue'
	const WxAuth =  require('@/utils/wxlogin');
	export default {
		components: {
			tkiBarcode,
			wybPopup
		},
		data() {
			return {
				isShowTip:false,
				isPaying:false,
				isCode:false,
				txcode:'',
				adressInfo: '', //收货地址
				addressUserName:'',//收货人
				warnMessage:'错误',//消息内容
				warnType:'warn',//消息类型  success/warn/info/error
				warnTime:1000,//消息提醒延长时间
				id:0, // 使用 marker点击事件 需要填写id
				title: 'map',
				covers: [
					{
					latitude: '',
					longitude: '',
					// iconPath: 'http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/map1.png'
					label:{},
				},
				],
				addressId:'',//收货地址id
				buyMode:1,//取药方式
				djMode:0,
				payState:null,//支付状态 (0-未支付 1-已支付 2-已派药 3-待退款)
				latitude: '',//纬度
				longitude: '',//精度
				evaluatetext:'',
				treatName:'',//就诊人
				recipeCode:'',//就诊卡号
				treatSex:'',//就诊人性别
				treatAge:'',//就诊人年龄
				treatWeight:'',//就诊人体重
				medDocOrdsId:'',//开单序号
				recipeId:'',//ID号
				refundRefuse: "", // 拒绝退费原因
				doctorDept:'',//科室
				entrustDoc:'',//诊断结果
				totalFee:'',//药品价格
				doctorName:'',//开方医生
				auditState:'',//审方状态 -1:未审核0:审核未通过 1:审核通过
				auditName:'',//审方药师
				auditDate:'',//日期
				auditRemark:'',//审核备注
				userRecipeDrug:[],//药品列表
				usrUserId:null,
				chinRecipeType:0,
				recipeInfo: undefined,
				nowrecipeId: undefined,
			};
		},
		onLoad(option) {
			WxAuth.onLogin();
			this.usrUserId=uni.getStorageSync("usrUserId")
			this.nowrecipeId = option.recipeId;
			if(option.scene){
				const opScene = option.scene;
				if(opScene){
				    const scene = decodeURIComponent(opScene);
					this.nowrecipeId = scene.split('=')[1]
				}
			}
			// console.log("处方:"+option.recipeId)
			//初始化数据
			this.getUserAddress(this.nowrecipeId);
		},
		onShow() {
			//初始化数据
			this.initData(this.nowrecipeId);
		},
		methods: {
			changeBuyMode(v){
				this.buyMode = v
			},
			changeDJMode(v){
				this.djMode = v
			},
			//导航
			Navigation(){
				let that = this;
				uni.openLocation({
					latitude: that.latitude,
					longitude: that.longitude,
					scale: 12
				});
				var map = uni.createMapContext('map');
				map.moveToLocation();
			},
			previewImage(){
				var that = this;
				 // 预览图片
				uni.previewImage({
					urls: [that.txcode],
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			//条形码生成的图片base64或图片临时地址
			code39(v){
				this.isCode = true;
				this.txcode = v;
				console.log(v)
			},
			setevaluatetext(e){
				this.evaluatetext = e.detail.value
			},
			getUserAddress(recipeId){
				var that = this;
				this.func.$request('wx/getUserAddress.tz',{recipeId : recipeId},'GET').then(res=>{
					if(res.data.success){
						that.addressId = res.data.result.id;
						that.adressInfo = res.data.result.address;
					}
				})
			},
			initData(recipeId){
				var that = this;
				var recipeId = recipeId;//处方id
				// var recipeId = 2503638
				that.func.$request('recipe/detail.tz',{recipeId : recipeId},'GET').then(res=>{
					if(res.data.success){
						var label = {};
						this.recipeInfo = res.data.result
						that.chinRecipeType=res.data.result.chinRecipeType;
						if(that.adressInfo==''){
							if(res.data.result.addressId){
								that.addressId = res.data.result.addressId;
								if(res.data.result.adressInfo){
									that.adressInfo = res.data.result.adressInfo;
								}
							}
						}
						if(typeof res.data.result.payState !='undefined'){
							that.payState = res.data.result.payState;
						}
						if(res.data.result.treatName){
							that.treatName = res.data.result.treatName;
						}
						if(res.data.result.recipeCode){
							that.recipeCode = res.data.result.recipeCode;
						}
						if(res.data.result.treatSex){
							that.treatSex = res.data.result.treatSex;
						}
						if(res.data.result.treatAge){
							that.treatAge = res.data.result.treatAge;
						}
						if(res.data.result.medDocOrdsId){
							that.medDocOrdsId = res.data.result.medDocOrdsId;
						}
						if(res.data.result.recipeId){
							that.recipeId = res.data.result.recipeId;
						}
						if(res.data.result.refundRefuse){
							that.refundRefuse = res.data.result.refundRefuse;
						}
						if(res.data.result.doctorDept){
							that.doctorDept = res.data.result.doctorDept;
						}
						if(res.data.result.entrustDoc){
							that.entrustDoc = res.data.result.entrustDoc;
						}
						if(res.data.result.totalFee){
							that.totalFee = res.data.result.totalFee;
						}
						if(res.data.result.doctorName){
							that.doctorName = res.data.result.doctorName;
						}
						if(res.data.result.auditName){
							that.auditName = res.data.result.auditName;
						}
						if(res.data.result.auditDate){
							that.auditDate = res.data.result.auditDate;
						}
						if(res.data.result.auditRemark){
							that.auditRemark = res.data.result.auditRemark;
						}
						if(res.data.result.userRecipeDrug){
							that.userRecipeDrug = res.data.result.userRecipeDrug;
						}
						
						if(res.data.result.addressUserName){
							that.addressUserName = res.data.result.addressUserName;
						}
						if(typeof res.data.result.buyMode!='undefined'&&res.data.result.payState!=0){
							that.buyMode = res.data.result.buyMode;
						}
						if(typeof res.data.result.auditState!='undefined'){
							that.auditState = res.data.result.auditState;
						}
						if(res.data.result.offcinaPostion){
							that.latitude = res.data.result.offcinaPostion.latitude;
							that.longitude = res.data.result.offcinaPostion.longitude;
							that.covers[0].latitude = res.data.result.offcinaPostion.latitude;
							that.covers[0].longitude = res.data.result.offcinaPostion.longitude;
							label.content = res.data.result.offcinaPostion.name;
							label.textAlign ='right';
							that.covers[0].label = label;
						}
						let f1 = res.data.result.drugsFee?res.data.result.drugsFee:0
						let f2 = res.data.result.diagnosisFee?res.data.result.diagnosisFee:0
						this.recipeInfo.drugsFee = f1*1 + f2*1
					}
				})
			},
			//格式化时间
			changeDateFormat(cellval) {
				if(cellval){
					var dateVal = cellval + "";
				　　　　if (cellval != null) {
				　　　　　　var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10));
				　　　　　　var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				　　　　　　var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				　　　　　　var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				　　　　　　var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				　　　　　　var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				　　　　　　return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + seconds;
				　　　　}
				}
			　},
			//导航
			Navigation(){
				let that = this;
				uni.openLocation({
					latitude: that.latitude,
					longitude: that.longitude,
					scale: 12,
					success: function() {
						
					}
				});
				var map = uni.createMapContext('map');
				map.moveToLocation();
			},
			refuseRefund() {
				uni.showToast({
					title: this.refundRefuse,
					icon: "error"
				})
			},
			payMonty(){
				this.$refs.popup.show()
				var parm = {};
				if(this.buyMode == 1){
					parm.addressId = this.addressId;
					uni.setStorageSync('addressId',this.addressId)
					parm.deliveryFee=this.recipeInfo.deliveryFee
				}else{
					parm.addressId = '-1';
					parm.deliveryFee=0
				}
			},
			pay1(){
					 uni.setStorageSync('orderType',2)
					 uni.setStorageSync('orderId',this.nowrecipeId)
					 let openId=uni.getStorageSync('openId')
					 if(this.buyMode == 1){
					 	console.log(1)
					 	uni.setStorageSync('deliveryFee',this.recipeInfo.deliveryFee)
					 }
					 this.$refs.popup.close()
					 var that=this
					let  data={
					 	hspId:this.hspId,
					 	recipeId:this.nowrecipeId,
					 	openId:openId,
					 	bizType:'04107'
					 }
					 that.func.$request('rczyywx/recipeSettlement.tz',data,'POST','application/x-www-form-urlencoded').then(res=>{
					 	wx.navigateToMiniProgram({
					 		appId: 'wx25ec5e985ebaacc7',
					 		path: 'pages/nativeLoading/index?webUrl=' + encodeURIComponent(res.data
					 			.errMsg),
					 		envVersion: 'trial'
					 	})
					 })
					 // this.func.$request('wx/getYbAuthInfo.tz',{hspId:'23840'},'GET','application/x-www-form-urlencoded').then(item=>{
					 // 	wx.navigateToMiniProgram({
					 // 	appId: 'wxeb22fc76d775615a',
					 // 	 path:item.data.result.path,
					 // 	 envVersion: 'release'
					 // 	    })
					 // })
			},
			//微信支付
			pay(){
				if(this.isPaying){
					return
				}
				this.isPaying = true
				
				if(this.recipeInfo.recipePayType.toString()=='0'){
					//通联支付 
					this.payMonty2()
					return
				}
				//获取code
				WxAuth.onLogin().then(code => {
					var that = this;
					var parm = {};
					let psf = 0;
					if(that.buyMode == 1){
						psf = (this.recipeInfo && this.recipeInfo.deliveryFee)?this.recipeInfo.deliveryFee:0
					}
					let yf = (this.recipeInfo && this.recipeInfo.drugsFee)?this.recipeInfo.drugsFee:0
					let djf = 0;
					if(that.djMode == 1){
						parm.decoctionFee=(this.recipeInfo && this.recipeInfo.decoctionFee)?this.recipeInfo.decoctionFee:0;
						djf = (this.recipeInfo && this.recipeInfo.decoctionFee)?this.recipeInfo.decoctionFee:0;
					}
					parm.recipeId = that.recipeId;
					parm.buyMode = that.buyMode;
					parm.thirdPayEnum = 'weixinApplet';
					parm.money = (yf*1000+psf*1000+djf*1000)/1000;
					
					if(that.buyMode == 1){
						parm.addressId = that.addressId;
					}else{
						parm.addressId = '-1';
					}
					parm.code = code;//code值(5分钟失效)
					that.func.$request('recipe/payment.tz',parm,'POST','application/x-www-form-urlencoded').then(item=>{
						if(item.data.success){
							var timestamp = item.data.result.timeStamp;
							var nonceStr = item.data.result.nonceStr;
							var packages = 'prepay_id='+item.data.result.prepayid;
							var paySign = item.data.result.sign;
							uni.requestPayment({
							    timeStamp: timestamp,
							    nonceStr: nonceStr,
							    package: packages,
							    signType: 'MD5',
							    paySign: paySign,
							    success: function (res) {
								   that.isPaying = false
							       that.warnMessage = '支付成功';
							       that.warnType = 'success';
							       that.$refs.popup.close();
								   that.payState = 1;
								   that.initData(that.nowrecipeId);
							    },
								fail() {
									that.isPaying = false
								}
							});
						}else{
							that.isPaying = false
							that.warnMessage = item.data.errMsg;
							that.warnTime  = 3000;
							that.$refs.popup.open();
						}
					}).catch(error=>{
						that.isPaying = false
						that.warnMessage = '支付失败';
						that.warnType = 'error';
						that.$refs.popup.open();
					})
				});
			},
			payMonty2(){
				let parm = {
					id : this.recipeId,
					type: 1,
					buyMode: this.buyMode
				};
				
				if(this.buyMode == 1){
					parm.addressId = this.addressId;
				}else{
					parm.addressId = '-1';
				}
				parm.userId = uni.getStorageSync("usrUserId");
				if(this.djMode == 1){
					parm.decoctionFee=(this.recipeInfo && this.recipeInfo.decoctionFee)?this.recipeInfo.decoctionFee:0;
				}
				this.func.$request('wx/getWxPayParams.tz',parm,'GET').then(res=>{
					if(res.data.success){
						 uni.openEmbeddedMiniProgram({
							appId: 'wxd395e529ea02b286',  
							extraData: {
								cusid: res.data.result.cusid,
								appid: res.data.result.appid, 
								orgid: res.data.result.orgid, 
								version: res.data.result.version, 
								trxamt: res.data.result.trxamt,
								reqsn: res.data.result.reqsn, 
								notify_url: res.data.result.notify_url, 
								body: res.data.result.body, 
								remark: res.data.result.remark, 
								validtime: res.data.result.validtime, 
								limit_pay: "", 
								randomstr: res.data.result.randomstr, 
								paytype: "W06", 
								sign:res.data.result.sign
							}
						 })
					}
				})
			},
			toAddress(){
				var that =this;	
				uni.navigateTo({
					url: '/pages/address/index?recipe='+that.recipeId+'&userId='+that.usrUserId+'&medDocInfoId=-1'
				});
				//获取监听事件
				uni.$once('returnPres',this.returnAdvisoryvideo);
			},
			returnAdvisoryvideo(data){
				this.addressId = data.addressId;
				this.adressInfo = data.adressInfo;
				this.addressUserName = data.addressUserName;
			}
		}
	};
</script>

<style lang="less">
	.add-btn{
		margin: auto;
		height: 88rpx;
		line-height: 88rpx;
		width: 90%;
		background: linear-gradient(90deg, #23E0D3 0%, #00BAAD 100%);
		box-shadow: 0px 20rpx 25rpx 0px rgba(0, 186, 173, 0.4);
		border-radius: 44rpx;
		color: #FFFFFF;
		text-align: center;
	}
	.add-btn-del{
		margin: auto;
		height: 88rpx;
		line-height: 88rpx;
		width: 90%;
		background: #D8D8D8;
		border-radius: 44rpx;
		color: #FFFFFF;
		text-align: center;
	}
	page {
		.bsdh{
			font-size: 31rpx;
			background-color: #F73809;
			color: #F7F7F7;
			width: 30%;
			padding-top: 10rpx;
			padding-bottom: 10rpx;
			margin-left: 90px;
			margin-top: 10px;

		}
		background: #74a6fd;

		image {
			width: 260rpx;
			margin: 0 auto;
			display: block;
		}
		.red{
			color: red;
		}
		.big {
			line-height: 44rpx;
		}

		.big::before {
			content: '';
			position: absolute;
			width: 44rpx;
			height: 44rpx;
			background: #74A6FD;
			border-radius: 50%;
			left: -25rpx;
			top: 0;
		}

		.big::after {
			content: '';
			position: absolute;
			width: 44rpx;
			height: 44rpx;
			background: #74A6FD;
			border-radius: 50%;
			right: -25rpx;
			top: 0;
		}

		.medicine>view {
			background: #efefef;
		}
		
		.check{
			width: 28rpx;
			height: 28rpx;
			margin-right: 15rpx;
		}
		.btns{
			width: 660rpx;
			height: 100rpx;
			line-height: 100rpx;
			border-radius: 10rpx;
			background: #74a6fd;
		}
		.evaluate{
			display: block;
			width: 170rpx;
			line-height: 60rpx;
			border: 1rpx solid #efefef;
			border-radius: 10rpx;
			
		}
		.star{
			width: 52rpx;
			height: 50rpx;
			margin:25rpx 20rpx;
		}
		.evaluatetext{
			width: 505rpx;
			height: 205rpx;
			border: 1rpx solid #EFEFEF;
			border-radius: 15rpx;
			margin: 0 auto;
		}
		.map{
			width: 626rpx;
			height: 400rpx;
		}
	}
	.part1 {
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
	}
	
	.imgs {
		display: flex;
	
		image {
			width: 120rpx;
			height: 97rpx;
			margin: 10rpx;
		}
	}
	
	.part2 {
		height: 100rpx;
		width: 96%;
		margin: 0 auto;
		border-bottom: 2rpx solid #ECECEC;
		display: flex;
		align-items: center;
	
		image {
			width: 70rpx;
			height: 30rpx;
		}
	}
	
	.part3 {
		height: 100rpx;
		width: 96%;
		margin: 0 auto;
		display: flex;
		align-items: center;
		border-bottom: 2rpx solid #ECECEC;
	
		image {
			width: 77rpx;
			height: 64rpx;
		}
	}
</style>
